package com.example.controller;


import com.example.common.R;
import com.example.entity.ShoppingCart;
import com.example.service.ShoppingCartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 购物车 前端控制器
 * </p>
 *
 * @author lw
 * @since 2023-01-31
 */
@RestController
@RequestMapping("/shoppingCart")
public class ShoppingCartController {
    @Autowired
    private ShoppingCartService shoppingCartService;

    @GetMapping("/list")
    public R<List<ShoppingCart>> list(){
        return shoppingCartService.getList();
    }
    @PostMapping("/add")
    public R<ShoppingCart> addCar(@RequestBody ShoppingCart shoppingCart){
        return shoppingCartService.addCar(shoppingCart);
    }
    @PostMapping("/sub")
    public R<ShoppingCart> sub(@RequestBody ShoppingCart shoppingCart){
        return shoppingCartService.addCar(shoppingCart);
    }
    @DeleteMapping("/clean")
    public R<String> clean(){
        return shoppingCartService.clean();
    }
}

